package com.aode.musicdetail.view.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import com.aode.common.bean.request.Request;
import com.aode.common.bean.response.Music;
import com.aode.downloadmusic.view.activity.DownloadActivity;
import com.aode.musicdetail.R;
import com.aode.musicdetail.databinding.ActivityMusicDetailBinding;

public class MusicDetailActivity extends AppCompatActivity {
    private ActivityMusicDetailBinding musicDetailBinding;
    private Music music;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        musicDetailBinding = DataBindingUtil.setContentView(this, R.layout.activity_music_detail);
        music = (Music) getIntent().getParcelableExtra("music");
        if(music!=null){
            musicDetailBinding.setMusic(music);
        }
        musicDetailBinding.setMusicdetail(MusicDetailActivity.this);
    }

    public void click(View view){
        int id = view.getId();
        if (id == R.id.iv_music_detail_collect) {
            //收藏

        } else if (id == R.id.iv_music_detail_download) {
            //下载
            Intent intent = new Intent();
            Bundle bundle = new Bundle();
            bundle.putParcelable("music",music);
            intent.putExtras(bundle);
            intent.setClass(this, DownloadActivity.class);
            startActivityForResult(intent, Request.MUSIC_DETAIL_TO_DOWNLOAD);
        }
    }
}
